<template>
  <div class="app-container">
    <!-- 头部组件，根据路由元信息决定是否显示 -->
    <Header v-if="showHeaderFooter" />
    
    <!-- 路由视图区域（用于显示所有页面内容） -->
    <transition name="page-fade">
      <router-view v-slot="{ Component }">
        <component :is="Component" />
      </router-view>
    </transition>
    
    <!-- 底部组件，根据路由元信息决定是否显示 -->
    <Footer v-if="showHeaderFooter" />
  </div>
</template>

<script setup>
import Header from '@/components/Header.vue'
import Footer from '@/components/Footer.vue'
import { computed } from 'vue'
import { useRoute } from 'vue-router'

const route = useRoute()

// 计算属性，根据当前路由的meta.showHeaderFooter决定是否显示Header和Footer
const showHeaderFooter = computed(() => {
  return route.meta.showHeaderFooter !== false // 默认显示，除非明确设置为false
})
</script>

<style>
/* 全局样式重置和优化 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  width: 100%;
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* 路由过渡动画 */
.page-fade-enter-active,
.page-fade-leave-active {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.page-fade-enter-from {
  opacity: 0;
  transform: translateY(20px);
}
.page-fade-leave-to {
  opacity: 0;
  transform: translateY(-20px);
}

/* 滚动条样式优化 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 4px;
  transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

/* 选择文本样式 */
::selection {
  background: rgba(102, 126, 234, 0.3);
  color: #2d3748;
}

::-moz-selection {
  background: rgba(102, 126, 234, 0.3);
  color: #2d3748;
}

/* 响应式断点 */
@media (max-width: 1200px) {
  .app-container {
    padding: 0;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 13px;
  }
}
</style>